Skip to content

perf(agc): memoize source failures of draw stages as for compute - #422

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:perf/graphics-failure-memo
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:perf/graphics-failure-memo

Conversation

@MichonGoddijn231849

@MichonGoddijn231849 MichonGoddijn231849 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What

SourceHandleFor remembers a source that failed to resolve and answers later lookups with the stored failure, but only for compute stages. A draw stage that cannot be resolved was resolved again on every draw: GTA V draws whose descriptor came through a lane-dependent chain repeated the walk and threw each time.

  • Draw stages are poisoned like compute stages. Their memo key also mixes the role and code address of every linked program, because the request's context hash leaves those out.
  • compileDrawStage takes the memoized failure through the existing poisoned out-parameter. The draw is rejected with that message instead of an exception, as Dispatch already does.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • ctest: all tests pass.
  • GTA V (PPSA04264), Prologue, APS5_PROFILE_DRAW=1:
    • time spent on skipped draws dropped from 1187 ms to 50 ms per 10 s (9.8 to 0.4 µs per draw packet);
    • the same draws are still skipped, with the same messages.
    • Measured on my branch that combines this change with my other open PRs. Those draws render since fix(shader): v_writelane_b32 ignores EXEC #411.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. perf(agc): draw cache keys on the user words a program reads, memoizes failures, serves data-only hits #291 (mine) memoizes failed draws in the draw cache, a different layer, but edits the same compileDrawStage call in Draw.cpp; whichever merges second keeps both changes
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

The source-handle memo poisoned only compute failures, so a draw stage whose resource
walk cannot resolve was recompiled, and threw, on every draw. Draw stages are now
poisoned too, keyed with the linked programs, and a memoized failure rejects the draw
without an exception.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

+1. My integration branch has carried a version of this without the linked-program key. On PPSA21564's world map, unwinding these repeated throws took about 19% of the queue worker's time on Linux (the guest libc's unwinder calls dl_iterate_phdr for every frame), and memoizing the draw-stage failures removed it. I'll switch my branch to this version, since it also keys on the linked programs.

oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 3, 2026
…#422

boykopovar#422 (MichonGoddijn231849) memoizes the same draw-stage source failures and
also keys the memo on the role and code address of every linked program,
which bab8026 lacked. It is picked after this integration's merge; the
draw-ahead path is adapted to it there.

This reverts commit bab8026.
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 3, 2026
…paration

boykopovar#422's compileDrawStage reports a memoized source failure through its
`rejected` argument. prepareDrawAhead (local) passes one and gives up the
preparation on a failure, so the worker draws as before and rejects the draw
from the memo without a throw, as bab8026's DrawPrepare hunk did.

The Pm4 test from bab8026 (a vertex stage's failure is memoized, answered
without a throw only to a caller that asks, and not for another context)
covers boykopovar#422's memo.
@oneandonlydean
oneandonlydean merged commit a874079 into boykopovar:main Oct 4, 2026
3 checks passed
@MichonGoddijn231849
MichonGoddijn231849 deleted the perf/graphics-failure-memo branch October 9, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants